Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cli command size #215

Merged
merged 3 commits into from
Jun 1, 2021
Merged

feat: add cli command size #215

merged 3 commits into from
Jun 1, 2021

Conversation

styfle
Copy link
Member

@styfle styfle commented Jun 1, 2021

Instead of nft build index.js && du -sh dist, this introduces a new command: nft size index.js.

I also updated the CLI output to be a little friendlier:

△ nft 0.12.2

Usage:

  $ nft [command] <file>

Commands:

  build    trace and copy to the dist directory
  print    trace and print to stdout
   size    trace and print size in bytes

@styfle styfle requested review from guybedford and ijjk June 1, 2021 15:43
@styfle styfle requested review from lucleray and Timer as code owners June 1, 2021 15:43
@codecov
Copy link

codecov bot commented Jun 1, 2021

Codecov Report

Merging #215 (ea36c58) into main (2b97d7d) will increase coverage by 0.20%.
The diff coverage is 90.90%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #215      +/-   ##
==========================================
+ Coverage   80.18%   80.39%   +0.20%     
==========================================
  Files          13       13              
  Lines        1413     1433      +20     
  Branches      535      537       +2     
==========================================
+ Hits         1133     1152      +19     
- Misses        109      110       +1     
  Partials      171      171              
Impacted Files Coverage Δ
src/cli.ts 83.01% <90.90%> (+4.23%) ⬆️
src/analyze.ts 87.76% <0.00%> (+0.23%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2b97d7d...ea36c58. Read the comment docs.

bytes += stat.size;
}
}
stdout.push(`${bytes} bytes total`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be preferable to make this KB by default, or choose between bytes or not. Here's an example function - https://stackoverflow.com/questions/10420352/converting-file-size-in-bytes-to-human-readable-string/14919494#14919494.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could potentially leverage pretty-bytes here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started going down that road but I wasn't sure if we wanted to use base 2 (1024) or base 10 (1000) to mean 1KB (I'll need to verify how the API does it) so I left that for a follow up PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps at least use numeric separators with a standard format like 123,456,789B?

Copy link
Contributor

@guybedford guybedford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition

@styfle styfle merged commit 05995af into main Jun 1, 2021
@styfle styfle deleted the add-size-cli branch June 1, 2021 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants